package com.siss.tenancy.elastic.client;

/**
 * 类名: UserClientFactory.java
 * 描述: 
 * 创建人: yingw
 * 创建时间: 2019年2月22日下午9:07:51
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserClientFactory implements FallbackFactory<UserClient> {
	 private static final Logger logger = LoggerFactory.getLogger(UserClientFactory.class);

    private final UserClientFallback userClientFallback;

    public UserClientFactory(UserClientFallback userClientFallback) {
        this.userClientFallback = userClientFallback;
    }

    @Override
    public UserClient create(Throwable cause) {       
    	logger.info("fallback-user; reason was Message: {}", cause.getMessage());
    	logger.info("fallback-user; reason was cause: {}", cause);
    	//打印下异常
        cause.printStackTrace();
        logger.info("fallback-user: Fallback 结束");
        return userClientFallback;
    }
}
